﻿<%@ Page Title="" Language="C#" MasterPageFile="~/module/Fontend.Master" AutoEventWireup="true"
    CodeBehind="ParentConversationDetails.aspx.cs" Inherits="mamnontuoitho7.module.ParentConversationDetails"
    ValidateRequest="false" %>

<%@ Import Namespace="mamnontuoitho7.AppCode" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <script language="javascript" type="text/javascript">
        function ClientMessage_Click() {

            var commentContent = trim(document.getElementById("<%= txtMessage.ClientID %>").value);
            var leng = commentContent.length;
            if (leng < 2 || leng > 1000) {
                alert("Cần gõ hơn 2 ký tự và không quá 1000 ký tự");
                return false;
            }
        }
        function MessageUpdate(i) {
            var commentContent = trim(document.getElementById("txtUpdateComment" + i).value);
            var leng = commentContent.length;
            if (leng < 2 || leng > 1000) {
                alert("Cần gõ hơn 2 ký tự và không quá 1000 ký tự");
                return false;
            }
        }
        function trim(str) {
            return str.replace(/^\s+|\s+$/g, "");
        }
    </script>
    <div class="accounts">
        <div class="login-name">
            <div class="login-name-left">
            </div>
            <span class="login-name-middle">
                <%= Session["fullname"].ToString()%></span>
            <div class="login-name-right">
            </div>
        </div>
        <div class="block-menu">
            <ul>
                <li class="active"><a href="ParentConversation.aspx">Các cuộc hội thoại</a></li>
                <li><a href="ParentKidList.aspx">Danh sách Bé</a></li>
                <li><a href="ParentWarning.aspx">Thông báo</a></li>
                <li><a href="ParentProfile.aspx">Thông tin tài khoản</a></li>
                <li><a href="ChangeAvatar.aspx">Thay đổi Avatar</a></li>
            </ul>
        </div>
        <div class="block-content">
            <div class="blocktable">
                <h1 class="list-conversation">
                    Cuộc hội thoại:
                    <%= _general.ReplaceSpecialCharacters( _dtConversation.Rows[0]["Topic"].ToString())%></h1>
                <div class="detailscomment">
                    <%
                        int _Amount = _dtMessage.Rows.Count;
                    %>
                    <input type="hidden" id="hihCommentAmount" value="<%= _Amount%>" />
                    <%--biến cầu nối chay js tren fontend--%>
                    <%
                        for (int i = 0; i < _Amount; i++)
                        {
                            bool tempbool = _message.checkMessageOwner(_dtMessage.Rows[i]["MessageID"].ToString(), Session["memberID"].ToString());
                    %>
                    <div class="commentdetail">
                        <img src="../images/avatar/teacher_parents/<%= (_dtMessage.Rows[i]["Avatar"].ToString() != "") ? _dtMessage.Rows[i]["Avatar"].ToString() : ConstantClass._memberDefaultAvatar %>?<%=DateTime.Now.Ticks %>"
                            alt="" />
                        <span class="arrow"><span></span></span>
                        <div id="showcontent<%= i%>" class="blockcontent" <%if (!tempbool){ %> style="background: #F6F6F6;"
                            <%} %>>
                            <div class="content">
                                <%= _general.ReplaceSpecialCharacters(_dtMessage.Rows[i]["MessageContent"].ToString())%>
                            </div>
                            <div class="info">
                                bởi <a href="ProfileInfo.aspx?MemberID=<%=_dtMessage.Rows[i]["MemberID"].ToString() %>"
                                    class="groupprofile">
                                    <%= _dtMessage.Rows[i]["FullName"].ToString()%></a> lúc:
                                <%= DateTime.Parse(_dtMessage.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%>
                                <% 
                                    if (tempbool)
                                    { %>
                                <a href="#editcontent" onclick="hide('showcontent<%= i%>'); showhide('editcontent<%= i%>');"
                                    class="buttonlink">Sửa</a>
                                <%} %>
                            </div>
                        </div>
                        <div id="editcontent<%= i%>" class="blockcontent">
                            <% if (tempbool)
                               { %>
                            <form method="post" action="ParentConversationDetails.aspx?ConversationID=<%=hid_ConversationID.Value %>"
                            id="formUpdate">
                            <div class="content">
                                <textarea id="txtUpdateComment<%= i%>" name="txtUpdateComment" class="textarea"><%= _dtMessage.Rows[i]["MessageContent"].ToString()%></textarea>
                                <input type="hidden" id="hidMessageID" name="hidMessageID" value="<%= _dtMessage.Rows[i]["MessageID"].ToString()%>" />
                                <input type="hidden" id="hidStatus" name="hidStatus" value="1" />
                            </div>
                            <div class="info">
                                bởi <a href="ProfileInfo.aspx?MemberID=<%=_dtMessage.Rows[i]["MemberID"].ToString() %>"
                                    class="groupprofile">
                                    <%= _dtMessage.Rows[i]["FullName"].ToString()%></a> lúc:
                                <%= DateTime.Parse(_dtMessage.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy")%>
                                <a href="#showcontent" onclick="hide('editcontent<%= i%>'); showhide('showcontent<%= i%>');"
                                    class="buttonlink">Hủy</a>
                                <button type="submit" class="buttoncomment" onclick="return MessageUpdate(<%= i%>)">
                                    Cập nhật
                                </button>
                            </div>
                            </form>
                            <%} %>
                        </div>
                    </div>
                    <% }%>
                </div>
            </div>
            <div id="container">
                <div class="pagination">
                    <%if (_currentbar > 1)
                      { %>
                    <a href="ParentConversationDetails.aspx?a=-1&ConversationID=<%=hid_ConversationID.Value %>"
                        class="pagecyan"><<</a>
                    <%}
                      for (int j = _beginPage; j <= _endPage; j++)
                      {
                          if (j == _pageflag)
                          {
                    %>
                    <a href="ParentConversationDetails.aspx?page=<%= j%>&ConversationID=<%=hid_ConversationID.Value %>"
                        class="pagecyan active">
                        <%= j%></a>
                    <% }
                        else
                        { %>
                    <a href="ParentConversationDetails.aspx?page=<%= j%>&ConversationID=<%=hid_ConversationID.Value %>"
                        class="pagecyan">
                        <%= j%></a>
                    <%  }
                    } %>
                    <%if (_currentbar < _totalBars)
                      { %>
                    <a href="ParentConversationDetails.aspx?a=1&ConversationID=<%=hid_ConversationID.Value %>"
                        class="pagecyan">>></a>
                    <%} %>
                </div>
            </div>
            <div class="blockform">
                <% if (_classCount != 0)
                   { %>
                <form id="form1" runat="server">
                <asp:HiddenField ID="hid_ConversationID" runat="server" />
                <asp:TextBox ID="txtMessage" runat="server" TextMode="MultiLine"></asp:TextBox><br />
                <asp:Button ID="btnMessage" runat="server" CssClass="buttons" Text="Trả lời" OnClick="btnMessage_Click"
                    OnClientClick="return ClientMessage_Click()" />
                </form>
                <%} %>
            </div>
        </div>
    </div>
</asp:Content>
